/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2023. All rights reserved.
 * Description: UDK cycles/timer for x86 architecture header file
 * Author: -
 * Create: 2021.4.19
 */

#ifndef UDK_CYCLES_X86_H
#define UDK_CYCLES_X86_H

#include <stdint.h>

static inline uint64_t udk_x86_rdtsc(void)
{
    union {
        uint64_t tsc_64;
        struct {
            uint32_t lo_32;
            uint32_t hi_32;
        };
    } tsc;

    asm volatile("rdtsc" : "=a"(tsc.lo_32), "=d"(tsc.hi_32));

    return tsc.tsc_64;
}

static inline uint64_t udk_rdtsc(void)
{
    return udk_x86_rdtsc();
}

#endif /* UDK_CYCLES_X86_H */